<template>
	<view class="login">
		<image class="logo" src="/static/image/logo@2x.png"></image>
		<view class="login-title">
			中国联通
			<br />
			5G智慧会诊云平台
		</view>
		<view>
			<input class="uni-input" type="text" v-model="phone" placeholder="输入手机号" />
			<input class="uni-input" type="password" v-model="code" placeholder="输入密码" />
		</view>
		<!-- <view class="input-group">
			<view class="input-row border">
				<image src="../static/image/iconzh1@2x.png"></image>
				<m-input class="m-input" type="text" clearable focus v-model="phone" placeholder="请输入账号"></m-input>
			</view>
			<view class="input-row">
				<image src="../static/image/Fill 1@2x (2).png"></image>
				<m-input displayable v-model="code" placeholder="请输入密码"></m-input>
			</view>
		</view> -->
		<!-- <view class="login-checkbox">
			<checkbox>自动登录</checkbox>
			<checkbox>记住密码</checkbox>
		</view> -->
		<view class="forget-pwd">
			<view @click="toPath">忘记密码？</view>
			<!-- <navigator url="../pwd/pwd">忘记密码？</navigator> -->
		</view>
		<view class="btn-row"><button type="primary" class="primary" @tap="bindLogin">登 录</button></view>
	</view>
</template>

<script>
import mInput from '../components/m-input.vue';
export default {
	components: {
		mInput
	},
	data() {
		return {
			providerList: [],
			hasProvider: false,
			phone: '15985469354',
			code: '123456',
			type: 2,
			positionTop: 0,
			isDevtools: false
		};
	},
	onLoad() {},
	methods: {
		toPath() {
			uni.navigateTo({
				url: './forgetPwd'
			});
		},
		getCode() {
			this.$http.post(`/treat/terminal/v1/user/send/code?phone=${this.phone}`).then(res => {});
		},
		getUserData() {
			this.$http.post(`/treat/web/v1/user/info`).then(res => {
				// 存储
				getApp().globalData.uid = res.data.userMark;
				uni.setStorageSync('uid', res.data.userMark);
				uni.setStorageSync('userName', res.data.relationName);
				getApp().globalData.tagging = '0';
			});
		},
		bindLogin() {
			// if(!(/^1[3456789]\d{9}$/.test(this.phone))){
			//  uni.showToast({
			//  	title:'请输入正确的手机号',
			// 	icon:'none'
			//  })
			// 	return
			// }
			if (!/^[a-zA-Z0-9]{6,18}$/.test(this.code)) {
				uni.showToast({
					title: '请输入正确的密码',
					icon: 'none'
				});
				return;
			}
			let params = {
				code: this.code,
				phone: this.phone,
				type: this.type
			};
			this.$http.post(`/treat/web/v1/user/login?account=${this.phone}&password=${this.code}&type=${this.type}`).then(res => {
				uni.setStorageSync('token', res.msg);
				this.getUserData();
				console.log(res.code);
				if (res.code == '200') {
					uni.navigateTo({
						url: './consultationList'
					});
				}
			},err => {
				// uni.showToast({
				// 	title: err.msg,
				// 	icon: 'none'
				// });
			})
			
			;
		}
	}
};
</script>

<style lang="less" scoped>
page {
	background: rgba(245, 246, 250, 1);
	display: flex;
}
.login {
	width: 1200px;
	min-height: 780px;
	background: rgba(255, 255, 255, 1);
	margin: auto;
	text-align: center;
	overflow: hidden;
	.logo {
		width: 230px;
		height: 168px;
		margin: 34px auto 10px;
		box-sizing: content-box;
	}
	.login-title {
		height: 118px;
		font-size: 42px;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: rgba(51, 51, 51, 1);
		line-height: 59px;
		margin-top: 20px;
		margin-bottom: 40px;
	}
	input {
		width: 578px;
		border-bottom: 1.58px solid rgba(213, 213, 213, 1);
		padding: 39.58px 0 14.25px;
		text-align: left;
		margin: auto;
		font-size: 19px;
	}
	.forget-pwd view {
		width: 570px;
		height: 70px;
		line-height: 70px;
		text-align: right;
		box-sizing: border-box;
		margin: 10px auto 30px auto;
		cursor: pointer;
		font-size: 18px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 147, 232, 1);
	}
	.login-checkbox {
		display: flex;
		justify-content: space-between;
		font-size: 25px;
		padding: 0 41.66px;
		margin-bottom: 127.77px;
	}
}
.action-row {
	display: flex;
	flex-direction: row;
	justify-content: center;
	margin-top: 93.05px;
}

.action-row navigator {
	color: #007aff;
	padding: 0 10px;
}
uni-button {
	font-size: 14px;
}
</style>
